package com.stylefeng.guns.modular.system.service.impl;

import com.stylefeng.guns.common.persistence.model.ProjectTable;
import com.stylefeng.guns.common.persistence.model.ProjectTableProperty;
import com.stylefeng.guns.modular.system.service.IProjectTableService;
import com.stylefeng.guns.modular.utils.GeneratorUtils;
import com.stylefeng.guns.modular.utils.ModifyConfig;
import org.apache.commons.io.FileUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * @author lmshe
 * @create 2018-07-06 9:41
 * @desc
 */
@Service
public class ProjectTableServiceImpl implements IProjectTableService{

    /**
     * 代码生成
     * @param projectTablePropertyList
     * @param projectTable
     * @return
     */
    @Override
    public String generatorCode(List<ProjectTableProperty> projectTablePropertyList, ProjectTable projectTable) {

        //生成mapping
        GeneratorUtils.generatorMapping(projectTablePropertyList,projectTable);
        //生成实体对象
        GeneratorUtils.generatorDomain(projectTablePropertyList,projectTable);
        //生成视图
        GeneratorUtils.generatorViewModel(projectTablePropertyList,projectTable);
        //生成查询条件model
        GeneratorUtils.generatorSearchModel(projectTable);
        //生成Service
        GeneratorUtils.generatorServices(projectTable);
        //生成profile
        GeneratorUtils.generatorProfiles(projectTable);
        //生成controller
        GeneratorUtils.generatorController(projectTable);
        //生成视图
        GeneratorUtils.generatorViews(projectTablePropertyList,projectTable);

        //修改相关配置文件
        ModifyConfig.modifyConfigs(projectTable);
        return null;
    }


}
